{% extends "base.html" %}

{% block content %}
<div class="row">
    <div class="col-md-6">
        <img src="{{ url_for('static', filename=product.image) }}" 
             class="img-fluid rounded" 
             alt="{{ product.name }}">
    </div>
    <div class="col-md-6">
        <h2>{{ product.name }}</h2>
        
        <!-- 库存状态 -->
        {% if product.stock <= 0 %}
            <div class="alert alert-danger">⛔ 该商品已售罄</div>
        {% elif product.stock <= 3 %}
            <div class="alert alert-warning">⚠️ 库存紧张！仅剩 {{ product.stock }} 件</div>
        {% else %}
            <div class="alert alert-success">✅ 库存充足：{{ product.stock }} 件</div>
        {% endif %}
        
        <p class="h3 text-danger">¥{{ product.price }}</p>
        <p>{{ product.description }}</p>
        
        {% if product.stock > 0 %}
            <a href="{{ url_for('add_to_cart', product_id=product.id) }}" 
               class="btn btn-primary btn-lg">
                💰 立即购买
            </a>
        {% else %}
            <button class="btn btn-secondary btn-lg" disabled>⛔ 售罄</button>
        {% endif %}
        
        <br><br>
        <a href="{{ url_for('index') }}" class="btn btn-outline-secondary">← 返回首页</a>
    </div>
</div>
{% endblock %}